import {Injectable} from '@angular/core';
import {ActivatedRouteSnapshot, RouterStateSnapshot, CanDeactivate, UrlTree} from '@angular/router';
import {Observable} from 'rxjs';
import {GestureLockPage} from '../pages/gesture-lock/gesture-lock.page';

@Injectable({
  providedIn: 'root'
})
export class LeaveGuard implements CanDeactivate<GestureLockPage> {

  canDeactivate(
    component: GestureLockPage,
    currentRoute: ActivatedRouteSnapshot,
    currentState: RouterStateSnapshot,
    nextState?: RouterStateSnapshot
  ): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
    return component.canLeave;
  }

}
